import request from '/@/utils/request';

// 订单查询

// 统计
export const fetchOrderStatics =  (params?: object) => {
	return request({
		url: '/order/count',
		method: 'get',
		params,
	});
}

// 列表
export const fetchOrderList =  (params?: object) => {
	return request({
		url: '/order',
		method: 'get',
		params,
		loading: true
	});
}

// 详情
export const fetchOrderDetail =  (params?: object) => {
	return request({
		url: '/order/detail',
		method: 'get',
		params,
		loading: true
	});
}

// 备注
export const fetchOrderRemark =  (data?: object) => {
	return request({
		url: '/order/remark',
		method: 'post',
		data,
	});
}

// 推送履约
export const fetchOrderPush =  (params?: object) => {
	return request({
		url: '/order/push',
		method: 'get',
		params,
	});
}

// 订单发货
export const fetchOrderShipments =  (data?: object) => {
	return request({
		url: '/order/send',
		method: 'post',
		data,
	});
}

// 取消订单
export const fetchOrderCancel =  (params?: object) => {
	return request({
		url: '/order/cancel',
		method: 'get',
		params,
	});
}

// 部分退款
export const fetchOrderPartRefund =  (data?: object) => {
	return request({
		url: '/order/partRefund',
		method: 'post',
		data,
	});
}

// 订单改价
export const fetchOrderChangePrice =  (data?: object) => {
	return request({
		url: '/order/changePrice',
		method: 'post',
		data,
	});
}

// 订单导出
export const fetchOrderExport =  (data?: object) => {
	return request({
		url: '/order/export',
		method: 'post',
		data,
		responseType: "blob",
	});
}


//---- 地址管理 -----
// 列表
export const fetchAddressList =  (params?: object) => {
	return request({
		url: '/order/address',
		method: 'get',
		params,
		loading: true
	});
}

// 新增
export const fetchCreateAddress = (data:any) => {
	return request({
		url: '/order/address/create',
		method: 'post',
		data,
	});
};

// 详情
export const fetchAddressDetail = (params:any) => {
  return request({
		url: '/order/address/detail',
		method: 'get',
		params,
	});
}

// 编辑
export const fetchUpdateAddress = (data:any) => {
	return request({
		url: '/order/address/update',
		method: 'post',
		data,
	});
};

// 删除
export const fetchDelAddress = (data:any) => {
  return request({
		url: '/order/address/delete',
		method: 'post',
		data,
	});
}

// 退款售后
// 列表
export const fetchAfterSaleList =  (params?: object) => {
	return request({
		url: '/order/afterMarketing',
		method: 'get',
		params,
		loading: true
	});
}

// 订单导出
export const fetchAfterSaleExport =  (data?: object) => {
	return request({
		url: '/order/afterMarketing/export',
		method: 'post',
		data,
		responseType: "blob",
	});
}

// 同意退货
export const fetchExpressAfterSale =  (data?: object) => {
	return request({
		url: '/order/afterMarketing/express',
		method: 'post',
		data,
	});
}

// 拒绝退货
export const fetchRefuseAfterSale =  (data?: object) => {
	return request({
		url: '/order/afterMarketing/refuse',
		method: 'post',
		data,
	});
}

// 拒收并同意换货/退货
export const fetcAgreeAfterSale =  (data?: object) => {
	return request({
		url: '/order/afterMarketing/agree',
		method: 'post',
		data,
	});
}

// 退货地址查询
export const fetcAfterSaleAddress =  (params?: object) => {
	return request({
		url: '/order/afterMarketing/address',
		method: 'get',
		params,
	});
}

// 协助退货
export const fetchHelpAfterSale =  (data?: object) => {
	return request({
		url: '/order/afterMarketing/help',
		method: 'post',
		data,
	});
}

// 同意或拒绝退款
export const fetchRefundAfterSale =  (data?: object) => {
	return request({
		url: '/order/afterMarketing/refund',
		method: 'post',
		data,
	});
}

// 采购需求单

export const fetchOrderBuy =  (params?: object) => {
	return request({
		url: '/order/buy',
		method: 'get',
		params,
	});
}

